import request from '../request.js'

export const findSelfProjectApi = (name, pageNum, pageSize) => {
  return request.get(`project/self/list?name=${ name || '' }&pageSize=${ pageSize || 10 }&pageNum=${ pageNum || 1 }`)
}

export const createProjectApi = (params) => {
  return request.post('/project/self/create', params, {
    headers: {
      'Content-Type': 'multipart/form-data',
    }
  })
}

export const findAllWorkGroupsApi = () => {
  return request.get(`project/self/workgroup/list`)
}

export const findUserByNameApi = (name) => {
  return request.get(`project/self/user/query?name=${ name || '' }`)
}

export const findProjectDetailsApi = (id) => {
  return request.get(`project/self/detail?id=${ id }`)
}

export const findProjectAllParticipantApi = (projectId) => {
  return request.get(`project/self/participant/all?projectId=${ projectId }`)
}

export const addProjectParticipantApi = (params) => {
  return request.post(`project/self/add/participant?participantId=${ params.participantId }&projectId=${ params.projectId }`)
}

export const updateProjectDetailsApi = (params) => {
  return request.post('project/self/update', params, {
    headers: {
      'Content-Type': 'multipart/form-data',
    }
  })
}

export const addProjectTaskApi = (params) => {
  return request.post(`project/task/add/task`, params)
}

export const findProjectTasksApi = (params) => {
  return request.get(`project/self/get/tasks?id=${ params.projectId }&status=${ params.status }`)
}

export const findProjectTaskDetailsApi = (params) => {
  return request.get(`project/task/task/detail?id=${ params.id }`)
}

export const findRequireGroupApi = (params) => {
  return request.get(`project/task/require/group?taskId=${ params.groupId }`)
}

export const findTaskRequiresApi = (params) => {
  return request.post(`project/task/require/list`, params)
}

export const findRequireDetailsApi = (params) => {
  return request.get(`project/require/require/detail?id=${ params.id }`)
}

export const findRequireTodoApi = (params) => {
  return request.get(`project/require/backlog/list`)
}

export const findRequireCreateApi = (params) => {
  return request.get(`project/require/create/list`)
}

export const findRequireDealApi = (params) => {
  return request.get(`project/require/deal/list`)
}

export const addRequireApi = (params) => {
  return request.post(`project/require/require/add`, params, {
    headers: {
      'Content-Type': 'multipart/form-data',
    }
  })
}

export const updateProjectTaskApi = (params) => {
  return request.post(`project/task/task/update`, params)
}

export const updateRequireApi = (params) => {
  return request.post(`project/require/require/update`, params)
}

export const addRequireDocumentApi = (params) => {
  return request.post(`project/require/document/add`, params, {
    headers: {
      'Content-Type': 'multipart/form-data',
    }
  })
}

export const deleteRequireDocumentApi = (params) => {
  return request.post(`project/require/document/delete`, params)
}

export const downLoadRequireDocumentApi = (params, onDownloadProgress) => {
  return request.post(`project/require/document/download`, params, {
    responseType: 'blob',
    onDownloadProgress
  })
}

export const deleteRequireApi = (params) => {
  return request.post(`project/require/require/delete`, params)
}

export const deleteTaskApi = (params) => {
  return request.post(`project/task/delete/task`, params)
}

export const deleteProjectApi = (params) => {
  return request.post(`project/self/delete`, params)
}